local gamelib = require "club.threecard.gamelib"

local M = gamelib.ui.element()

local TIME = 3

function M:ctor(res)
    self.res = res or "club.threecard.slotlib/fx/common.b:jackpot_win"
    self.value = nil
end

function M:play(value, parent)
    self.value = value
    self.parent = parent
    self:lazy("on_play")
    return TIME
end

function M:close()
    if not self.loaded then
        self:hide()
        return
    end
    self.animator:Play("exit")
end

function M:on_play()
    self.transform:SetParent(self.parent, false)
    self:show()

    self.animator:Play("enter")
    gamelib.utility.digit(self.value_txt, 0, self.value, nil, TIME - 0.5)
    self.value = nil
end

return M